package com.example.myfirstgame.helper;


public class FramePerSecondViewer {

	private static long lastSystemTime = 0;
	private static final int UPDATE_COUNTER = 25;
	private static long updates = 0;
	private static float fps = 0;
	
	public static String getFps() {
		return String.valueOf(fps);
	}

	public static void update(){
		if (lastSystemTime == 0){
			lastSystemTime = System.currentTimeMillis();
		}else {
			updates ++;
			if (updates%UPDATE_COUNTER == 0){
				long deltaT = System.currentTimeMillis()- lastSystemTime;
				lastSystemTime = System.currentTimeMillis();
				float seconds = ((float)deltaT) / 1000; 
				fps = ((float)UPDATE_COUNTER)/seconds;
			}
		}
	}
}
